package com.school.support.listener;

import com.school.gift.domain.Skim;
import com.school.gift.service.SkimService;
import com.school.gift.service.SysConfigService;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
import zhibi.common.util.ip.IPUtil;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;
import java.util.Date;

/**
 * Created by 执笔 on 2017/3/21.
 */
public class SkimSessionListener implements HttpSessionListener {

    @Override
    public void sessionCreated(HttpSessionEvent se) {
        ServletContext servletContext = se.getSession().getServletContext();
        WebApplicationContext webApplicationContext = WebApplicationContextUtils.findWebApplicationContext(servletContext);
        SkimService skimService = webApplicationContext.getBean(SkimService.class);
        Skim skim = new Skim();
        skim.setAddtime(new Date());
        skim.setSession(se.getSession().getId());
        skimService.insertSelective(skim);
    }
}
